package com.starbooks.tmail.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.UUID;

@Controller
public class AuthController {

  @GetMapping("/login")
  public String loginPage(HttpServletRequest req){
    return "login";
  }

  @GetMapping("/logout")
  public String logout(HttpServletRequest req){
    HttpSession session = req.getSession();
    session.invalidate();
    return "redirect:/home";
  }

  @PostMapping("/login")
  public String login(HttpServletRequest req){
    HttpSession session = req.getSession();
    session.setAttribute("appID",  UUID.randomUUID().toString());
    return "redirect:/home";
  }



}
